<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户注册页</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/signIn.css">
</head>

<body>
    <div class="nav">
        <img src="pic/login.png" alt="">
        <span class="blog-title">生活点滴志</span>
        <div class="space"></div>
        <a class="nav-span" href="blog_list.html">主页</a>
        <a class="nav-span" href="blog_edit.html">分享生活</a>
    </div>

    <div class="container-signIn">
        <div class="signIn-dialog">
            <h3>注册</h3>
            <div class="row">
                <span>用户名</span>
                <input type="text" name="username" id="username">
            </div>
            <div class="row">
                <span>密码</span>
                <input type="password" name="password" id="password">
            </div>

            <div class="row">
                <button id="signIn" onclick="signIn()">注册</button>
            </div>

        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script>

        function signIn() {
            $.ajax({
                type: "get",
                url:"/user/signIn",
                data:{
                    userName: $("#username").val(),
                    password: $("#password").val(),

                },
                success:function(result) {
                    console.log(result.code);
                    console.log(result.errorInfo);
                    if(result.code == 200) {
                        alert("注册成功");
                        location.href = "blog_login.html";
                    }else if(result.code == -3) {
                        alert("密码不符合要求");
                    }else if(result.code == -4) {
                        alert("密码不符合要求");
                    }else {
                        alert("用户名或密码为空");
                    }
                    $("#username").val('');
                    $("#password").val('');
                },
                error: function(error) {
                    console.log(error);
                }
            });
        }

    </script>
    
</body>
</html>